import { cn } from '@/utils/cn-merge';
import { Button as AntdButton } from 'antd';
import type { ButtonProps } from 'antd';
import '../styles/button.scss';

interface CustomButtonProps extends Omit<ButtonProps, 'type'> {
  className?: string;
  type?: ButtonProps['type'] | 'secondary';
}

export const Button = ({ className, type, ...props }: CustomButtonProps) => {
  const buttonClassName = cn(
    'rg-button',
    type === 'secondary' && 'rg-button-secondary',
    className
  );

  // 当 type 为 secondary 时，传递给 AntdButton 的 type 为 undefined（使用默认样式）
  const antdType = type === 'secondary' ? undefined : type;

  return <AntdButton className={buttonClassName} type={antdType} {...props} />;
};

export default Button;
